home *** CD-ROM | disk | FTP | other *** search
/ FishMarket 1.0 / FishMarket v1.0.iso / fishies / 476-500 / disk_488 / lordofhosts / lohsrc.lzh / joymouse.c < prev    next >
C/C++ Source or Header  |  1991-05-10  |  2KB  |  62 lines

  1. /* LORD OF HOSTS - joymouse.c --- Maus-Joystick-Umschalter */
  2.  
  3. #include "Lord.h"
  4.  
  5. extern struct IOStdReq *IOReq;
  6. extern ULONG JoyMouseData;
  7. BOOL joymouse_on;
  8. struct Interrupt Input_Handler;
  9. #pragma regcall(JoyMouseHandler(a0,a1))   /* dann brauche ich keinen Assembler-
  10.                                              Stub für die Parameter */
  11.  
  12. struct InputEvent *JoyMouseHandler (struct InputEvent *Event, ULONG *Data)
  13. /* Dies ist das Stück Interrupt-Code, das sich jede Mausbewegung schnappt,
  14.    bevor Intuition selbst drankommt, sie "streckt" (und alle anderen Events
  15.    durchläßt) */
  16. {
  17.    if (Event->ie_Class == IECLASS_RAWMOUSE)
  18.    {
  19.       Event->ie_X *= *Data;
  20.       Event->ie_Y *= *Data;
  21.    }
  22.    return Event;
  23. }
  24.  
  25. void swapjoymouse(BOOL what)
  26.    /* swapjoymouse(TRUE) schaltet Joymouse an, FALSE dagegen aus */
  27. {
  28.    UBYTE Type,Port;
  29.    if (what == TRUE)
  30.    {
  31.       Type = GPCT_RELJOYSTICK;   /* Joystick als Eingabegerät */
  32.       Port = 1;                  /*          am Gameport 2    */
  33.       Input_Handler.is_Code = (VOID (*)())JoyMouseHandler;
  34.       Input_Handler.is_Data = (APTR) &JoyMouseData;
  35.       Input_Handler.is_Node.ln_Pri = 51;
  36.       IOReq->io_Data = (APTR) &Input_Handler;
  37.       IOReq->io_Command = (UWORD) IND_ADDHANDLER;
  38.       DoIO((struct IORequest *)IOReq);             /* Handler einbinden */
  39.    }
  40.    else
  41.    {
  42.       Type = GPCT_MOUSE;         /* Maus als Eingabegerät */
  43.       Port = 0;                  /*      am Gameport 1    */
  44.       IOReq->io_Data = (APTR) &Input_Handler;
  45.       IOReq->io_Command = (UWORD) IND_REMHANDLER;
  46.       DoIO((struct IORequest *)IOReq);             /* Handler entfernen */
  47.    }
  48.  
  49.    /* Port wechseln */
  50.    IOReq->io_Data = (APTR) &Port;
  51.    IOReq->io_Length = 1;
  52.    IOReq->io_Command = (UWORD) IND_SETMPORT;
  53.    DoIO((struct IORequest *)IOReq);
  54.  
  55.    /* Controllertyp umschalten */
  56.    IOReq->io_Data = (APTR) &Type;
  57.    IOReq->io_Length = 1;
  58.    IOReq->io_Command = (UWORD) IND_SETMTYPE;
  59.    DoIO((struct IORequest *)IOReq);
  60.    joymouse_on = what;
  61. }
  62.